package cn.gemiman.daoyi.module.iot.open.jhl.mq.consumer;

import cn.gemiman.daoyi.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
import cn.gemiman.daoyi.module.iot.controller.admin.kafkamsglogs.vo.KafkaMsgLogsSaveReqVO;
import cn.gemiman.daoyi.module.iot.open.jhl.mq.message.JhlIotED767RedisStreamMessage;
import cn.gemiman.daoyi.module.iot.service.kafkamsglogs.KafkaMsgLogsService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class JhlIotED767RedisStreamMessageConsumer extends AbstractRedisStreamMessageListener<JhlIotED767RedisStreamMessage> {

    @Resource
    private KafkaMsgLogsService equipmentMsgLogsService;

    @Override
    public void onMessage(JhlIotED767RedisStreamMessage message) {
        equipmentMsgLogsService.createKafkaMsgLogs(
                new KafkaMsgLogsSaveReqVO()
                        .setMsg(message.getBody())
                        .setTopics(message.getStreamKey())
                        .setBootstrapServers(message.getClientIp())
                        .setConsumerGroupId("ED767")
                        .setViewed(false)
        );
    }
}
